﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace DEMO.WCF_API.Services
{
    public class EmployeeSVC : DEMO.WCF_API.Contracts.IEmployee
    {
        public IEnumerable<DEMO.WCF_API.Contracts.Employee> getEmployees()
        {
            try
            {
                DEMO.DataLayer.DEMOEntities db = new DEMO.DataLayer.DEMOEntities();

                var Employees = from p in db.DM_Employee
                                join c in db.DM_EmployeeDetail on p.DME_ID equals c.DMED_DME_ID
                                where p.DME_Flag == 1
                                select new DEMO.WCF_API.Contracts.Employee { Email = p.DME_EmailID, Name = c.DMED_FName + " " + c.DMED_LName, EmployeeID = p.DME_ID };
                return Employees;


                DEMO.DataLayer.DEMOEntities db1 = new DEMO.DataLayer.DEMOEntities();
               
                db1.DM_Employee.Where(M => M.DME_ID == 1);

                var emp = from pz in db.DM_Employee
                          where pz.DME_ID == 1
                          select new {  pz.DME_EmailID, pz.DME_Password };

            }
            catch (Exception ex)
            {

                throw ex;
            }
        }
        public DEMO.WCF_API.Contracts.Employee getEmployeeById(Int64 EmployeeID)
        {
            try
            {
                DEMO.DataLayer.DEMOEntities db = new DEMO.DataLayer.DEMOEntities();
                var Employees = (from p in db.DM_Employee
                                 join c in db.DM_EmployeeDetail on p.DME_ID equals c.DMED_DME_ID
                                 where p.DME_Flag == 1 && p.DME_ID == EmployeeID
                                 select new DEMO.WCF_API.Contracts.Employee { Email = p.DME_EmailID, Name = c.DMED_FName + " " + c.DMED_LName, EmployeeID = p.DME_ID })
                                .SingleOrDefault();
                return Employees;
            }
            catch (Exception ex)
            {

                throw ex;
            }
        }
    }
}